"""
    AuthUser lookup, needs for link to AuthUser's instances.
"""

from mnemoply import model
from mnemoply.controllers.lookup import LookupController, TableCol, SQLObjectLookupDataSource
from mnemoply.controllers.crud import CRUDController

class AuthUserController(LookupController, CRUDController):
    model_object = model.AuthUser
    lookup_columns = [
        TableCol(name='display_name', caption=_("Display name")),
        TableCol(name='user_name', caption=_("User name")),
    ]
    view_fields = [
        'display_name',
        'user_name',
        'personID',
        'officeID',
    ]

    edit_fields = view_fields + ['password']

    def __init__(self):
        LookupController.__init__(self,
            data_source=SQLObjectLookupDataSource(self.model_object),
            columns=self.lookup_columns,
            mass_actions_class=self.model_object,
            title='AuthUser',
        )
        CRUDController.__init__(self, model_object=self.model_object)

exposed = AuthUserController()
